home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume24 / chemtab / part01 next >
Encoding:
Internet Message Format  |  1991-03-12  |  51.9 KB

  1. Subject:  v24i036:  Manipulate data on the chemical elements, Part01/03
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 5975ff77 725e468c 4526f97d 2106b725
  5.  
  6. Submitted-by: "J.E. King" <jek5036@ultb.isc.rit.edu>
  7. Posting-number: Volume 24, Issue 36
  8. Archive-name: chemtab/part01
  9.  
  10. Chemtab was designed in conjunction with the faculty in the science
  11. department at the Lincoln-Sudbury Regional High School.  The database does a
  12. variety of functions:
  13.  
  14.     1) Graph elemental data (x vs y)
  15.     2) Select a set of elements from given parameters
  16.     3) Look at a certain element and display all known information
  17.        (at least, all input data) on the element.
  18. It is a screen-oriented program with extensive on-line help.
  19.  
  20. All elemental information in this program has been extracted from the
  21. following sources:
  22.     CRC Handbook of Chemistry & Physics, 63rd edition, 1982-1983
  23.     CRC Handbook of Chemistry & Physics, 70th edition, 1989-1990
  24.  
  25.  
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then feed it
  28. # into a shell via "sh file" or similar.  To overwrite existing files,
  29. # type "sh file -c".
  30. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  31. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  32. # Contents:  README README.FIRST dogph.c doregisgph.c elist esort.c
  33. #   looke.c main.c
  34. # Wrapped by rsalz@litchi.bbn.com on Wed Mar 13 13:55:18 1991
  35. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  36. echo If this archive is complete, you will see the following message:
  37. echo '          "shar: End of archive 1 (of 3)."'
  38. if test -f 'README' -a "${1}" != "-c" ; then 
  39.   echo shar: Will not clobber existing file \"'README'\"
  40. else
  41.   echo shar: Extracting \"'README'\" \(1337 characters\)
  42.   sed "s/^X//" >'README' <<'END_OF_FILE'
  43. XChemTab - A Periodic Table (of the elements) Database
  44. X
  45. XChemtab was written at Lincoln-Sudbury Regional High School during the 1989
  46. Xto 1990 school year.  Chemtab was completed further at Rochester Institute
  47. Xof Technology.
  48. X
  49. XChemtab was designed in conjunction with the faculty in the science
  50. Xdepartment at the Lincoln-Sudbury Regional High School.  The database does a
  51. Xvariety of functions:
  52. X
  53. X    1) Graph elemental data (x vs y)
  54. X    2) Select a set of elements from given parameters
  55. X    3) Look at a certain element and display all known information
  56. X       (at least, all input data) on the element.
  57. X
  58. XAll elemental information in this program has been extracted from the
  59. Xfollowing sources:
  60. X    CRC Handbook of Chemistry & Physics, 63rd edition, 1982-1983
  61. X    CRC Handbook of Chemistry & Physics, 70th edition, 1989-1990
  62. X
  63. Xo All whole numbers, if rounded, are rounded on the premise that:
  64. X  .01 to .49 considered rounded down
  65. X  .50 to .99 considered rounded up
  66. X
  67. Xo Ionization Energy found in the following manner: (to compromise the
  68. X  chemistry courses at the high school)
  69. X    All figures based on the table of "IONIZATION POTENTIALS", pages
  70. X    E-64 and E-65(82-83), column I, then multiplied by 23.  Rounded.
  71. X
  72. XChemtab; written in C (1990) by Jim King (pulsar@lsrhs)
  73. XChemtab V2.01; (overlay from V1) written in C (1991) by Jim King
  74. X                        (jek5036@ultb.isc.rit.edu)
  75. END_OF_FILE
  76.   if test 1337 -ne `wc -c <'README'`; then
  77.     echo shar: \"'README'\" unpacked with wrong size!
  78.   fi
  79.   # end of 'README'
  80. fi
  81. if test -f 'README.FIRST' -a "${1}" != "-c" ; then 
  82.   echo shar: Will not clobber existing file \"'README.FIRST'\"
  83. else
  84.   echo shar: Extracting \"'README.FIRST'\" \(2532 characters\)
  85.   sed "s/^X//" >'README.FIRST' <<'END_OF_FILE'
  86. XJim King - January 1991
  87. X
  88. XChemtab supports the following devices:
  89. X    ANY terminal which can utilize the curses screen functions
  90. X    * Graphic Periodic Table - ANY VT1XX compatible
  91. X    * Graphing routine (normal) - any curses terminal
  92. X    * Graphics routing (ReGIS) - any ReGIS compatible (VT240, VT3XX)
  93. X    
  94. X    Chemtab was designed to work on any terminal that has an entry
  95. Xin the /etc/termcap file and has cursor movement sequences in that
  96. Xentry!
  97. X
  98. XHow to setup Chemtab to work at your site..
  99. X
  100. XWARNING: Chemtab has only been tested under Ultrix 3.1 on a VAX 11/780,
  101. X     and a DEC 5810 RISC Ultrix 4.1 machine.  Chemtab, as is, will
  102. X     probably only work for BSD compatible systems.  SYSV compatibility
  103. X         is on it's way!  I promise!  Since chemtab uses curses, it should
  104. X     prove to be portable.
  105. X
  106. XAny comments, suggestions, bugs can be reported to:
  107. X    jek5036@ultb.isc.rit.edu (formerly pulsar@xait.xerox.com!lsrhs)
  108. X
  109. XHow to setup:
  110. X(1) Change the Makefile to suit your site.  Currently, the makefile will
  111. X    compile with cc, with the -O option for optimization, and the new
  112. X    ReGIS flag for DEC ReGIS compatible terminals.
  113. X(2) Change tune.h to suit your needs.
  114. X(3) Change the directions on how to get to your printer at the end of cleanup.c
  115. X    Or, just remove those print statements.  (The statement you want to change
  116. X    is in comments.  This is only helpful if you are running a classroom full
  117. X    of students, each wanting a printout and not knowing how to get it.)
  118. X(4) Type the command, 'make'
  119. X(5) There are some text files which chemtab needs to use, namely:
  120. X    elist, pertab, pertab_graphic, online_help, closevalues
  121. X    These should be put in a library directory somewhere where chemtab
  122. X    can read all of these.  In that same directory, chemtab will need to
  123. X    write to two files: logfile (if you want one) and binlist (binary
  124. X    element list (faster to read in)).  Please make this so.  I would
  125. X    have incorporated it into the Makefile but some people would rather
  126. X    make sure it worked for them...
  127. X
  128. XThat SHOULD be the extent of it.. but don't quote me on that.  I am the
  129. Xauthor, and I am not held responsible for any damage the program might cause,
  130. Xhowever it's not programmed to do any damage whatsoever.
  131. X
  132. XI realize that the directions are sketchy, but I am a programmer,
  133. Xnot a documenter (or a commenter for that matter)..
  134. X
  135. XIf you decide to use this program in a classroom environment, please send me
  136. Xmail over the internet at jek5036@ultb.isc.rit.edu.  I would love to hear
  137. Xfrom anyone who uses chemtab 2.01!  Thanks..            - Jim
  138. END_OF_FILE
  139.   if test 2532 -ne `wc -c <'README.FIRST'`; then
  140.     echo shar: \"'README.FIRST'\" unpacked with wrong size!
  141.   fi
  142.   # end of 'README.FIRST'
  143. fi
  144. if test -f 'dogph.c' -a "${1}" != "-c" ; then 
  145.   echo shar: Will not clobber existing file \"'dogph.c'\"
  146. else
  147.   echo shar: Extracting \"'dogph.c'\" \(7770 characters\)
  148.   sed "s/^X//" >'dogph.c' <<'END_OF_FILE'
  149. X/*
  150. X * chemtab - a periodic table data base (C) 1990 Jim King (pulsar@lsrhs)
  151. X *
  152. X * dogph.c    Contains graphing procedures
  153. X */
  154. X
  155. X#include <curses.h>
  156. X#include "windows.h"
  157. X#include <stdio.h>
  158. X#include <math.h>
  159. X#include "tune.h"
  160. X#include "variables.h"
  161. X#include "element.h"
  162. X#include "graph.h"
  163. X#include "undefs.h"
  164. X
  165. X/*
  166. X * numr(ch)
  167. X *    input:    ch - char - input to determine output
  168. X *    output:    return() - int
  169. X *
  170. X * purpose:    to print the top line of the graph, x vs. y, we need
  171. X *        the array number of the chosen function, array gname[]
  172. X *        found in graph.h...
  173. X */
  174. Xnumr(ch)
  175. Xchar    ch;
  176. X{
  177. X    char    luk[12];
  178. X    int    i;
  179. X
  180. X    strcpy(luk, " abcdefghij");
  181. X    for (i = 1; i < 11; i++)
  182. X        if (ch == luk[i]) return(i);
  183. X}
  184. X
  185. Xfixup(win)
  186. XWINDOW    *win;
  187. X{
  188. X    wmove(win, 0, 0);
  189. X    wmove(btm, 0, 0);
  190. X    wmove(win, 0, 0);
  191. X    move(0, 0);
  192. X    refresh();
  193. X    wrefresh(btm);
  194. X    wrefresh(win);
  195. X}
  196. X
  197. Xextern void find();
  198. X
  199. X/*
  200. X * dogph() - no input
  201. X *
  202. X * purpose:    This is the main graphing routine.
  203. X */
  204. Xdogph()
  205. X{
  206. X    struct    elem    *tmp;
  207. X    char    c, str[80];
  208. X    int    i, j, count;
  209. X
  210. X    for (i = 0; i < 70; i++)        /* clear the x axis points */
  211. X        xaxis[i] = 0;
  212. X    for (i = 0; i < 21; i++)        /* clear the y axis points */
  213. X        yaxis[i] = 0;
  214. X
  215. Xl2:    wclear(graph); wrefresh(graph); clear(); refresh();
  216. X    menu("Graphing Module");
  217. X    mvwaddstr(mn, 0, 0, "a] Atomic Number");
  218. X    mvwaddstr(mn, 1, 0, "b] Atomic Mass");
  219. X    mvwaddstr(mn, 2, 0, "c] Melting Temp.");
  220. X    mvwaddstr(mn, 3, 0, "d] Boiling Temp.");
  221. X    mvwaddstr(mn, 4, 0, "e] Ionization Energy");
  222. X    mvwaddstr(mn, 5, 0, "f] Electronegativity");
  223. X    wrefresh(mn);
  224. X    wmove(mn, 6, 0);
  225. X    wclrtoeol(mn);
  226. X    mvwaddstr(mn, 6, 0, "g] Specific Heat");
  227. X    wrefresh(mn);
  228. X    mvwaddstr(mn, 7, 0, "h] Density");
  229. X    mvwaddstr(mn, 8, 0, "i] Atomic Radius");
  230. X    mvwaddstr(mn, 9, 0, "j] Discovery Year");
  231. X    mvwaddstr(mn, 10, 0, "Graphing by this, across the X axis.");
  232. X    mvwaddstr(mn, 13, 0, "*** Due to lack of information at this time, graphs beyond");
  233. X    mvwaddstr(mn, 14, 0, "*** Atomic number 86 may be misleading.  The program is designed");
  234. X    mvwaddstr(mn, 15, 0, "*** to compensate, but nothing is perfect.");
  235. X    mvwaddstr(mn, 16, 0, ">>> PRESS RETURN TO RETURN TO MAIN MENU.");
  236. Xfirst:    mvwaddstr(mn, 11, 0, "Your choice: ");
  237. X    wrefresh(mn);                /* collect their choices */
  238. X    cur = mn; xp = 14; yp = 11;
  239. X    crmode();
  240. X    noecho();
  241. X    c1 = getchar();    /* X axis chc */
  242. X    if (c1 == '\n') { wclear(mn); return; }
  243. X    if (c1 == '?') { help(3); goto first; }
  244. X    if (c1 < 'a' || c1 > 'j')
  245. X        goto first;
  246. X    for (i = 12; i < 17; i++) {
  247. X        wmove(mn, i, 0); wclrtoeol(mn);
  248. X    }
  249. X
  250. X    find(c1, e->anum);
  251. X    xmax = xmin = x;
  252. X    if (gtot > 0) {
  253. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  254. X            find(c1, tmp->anum);
  255. X            if (x == -999.0) continue;
  256. X            if (x > xmax) xmax = x;
  257. X            if (x < xmin) xmin = x;
  258. X        }
  259. X    } else {
  260. X        for (i = 1; i < gtot; i++) {
  261. X            find(c1, sub1[i]);
  262. X            if (x == -999.0) continue;
  263. X            if (i == 1) xmax = xmin = x;
  264. X            else {
  265. X                if (x > xmax) xmax = x;
  266. X                if (x < xmin) xmin = x;
  267. X            }
  268. X        }
  269. X    }
  270. X
  271. X    mvwaddstr(mn, 10, 0, "If you would rather use the maximum and minimum values of");
  272. X    mvwaddstr(mn, 11, 0, "all the elements, hit RETURN once.");
  273. X    wmove(mn, 12, 0); wprintw(mn, "All the element's values: Minimum %f, Maximum %f", xmin, xmax);
  274. Xl4:    mvwaddstr(mn, 13, 0, "What range, X Minimum? ");
  275. X    wrefresh(mn);
  276. X    cur = mn; xp = 24; yp = 13;
  277. X    echo(); nocrmode();
  278. X    gets(str);
  279. X    if (str[0] == '?') { help(4); goto l4; }
  280. X    if (!strlen(str)) {
  281. X        xmin = -999;
  282. X        goto nt;
  283. X    }
  284. X    xmin = atof(str);
  285. X    fixup(mn); fixup(stdscr);
  286. X    mvwaddstr(mn, 13, 0, "What range, X Maximum [RETURN for value above]? ");
  287. X    wrefresh(mn);
  288. X    cur = mn; xp = 48; yp = 13;
  289. X    echo(); nocrmode();
  290. X    gets(str);
  291. X    if (strlen(str))
  292. X        xmax = atof(str);
  293. X    fixup(mn);
  294. X    
  295. Xnt:    wmove(mn, 10, 0); wclrtoeol(mn); wmove(mn, 11, 0); wclrtoeol(mn);
  296. X    mvwaddstr(mn, 10, 0, "Graphing by this, down the Y axis.   ");
  297. Xscnd:    wmove(mn, 12, 0); wclrtoeol(mn); wmove(mn, 13, 0); wclrtoeol(mn);
  298. X    mvwaddstr(mn, 11, 0, "Your choice: ");
  299. X    wrefresh(mn);
  300. X    cur = mn; xp = 14; yp = 11;
  301. X    noecho(); crmode();
  302. X    c2 = wgetch(mn); /* Y axis chc */
  303. X    if (c2 == '?') { help(5); goto scnd; }
  304. X    if (c2 < 'a' || c2 > 'j')
  305. X        goto scnd;
  306. X    noecho();
  307. X
  308. X    wclear(mn); wrefresh(mn);
  309. X    clear(); refresh();
  310. X    /* Here we find the x axis max and min values */
  311. X    /* if they are not already defined */
  312. X    if (xmin == -999) {
  313. X        find(c1, e->anum);
  314. X        xmax = xmin = x;
  315. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  316. X            find(c1, tmp->anum);
  317. X            if (x == -999.0) continue;
  318. X            if (x > xmax) xmax = x;
  319. X            if (x < xmin) xmin = x;
  320. X        }
  321. X    }
  322. X
  323. X    /* Here we find the y axis min and max values */
  324. X
  325. X    find(c2, e->anum);
  326. X    ymax = ymin = x;
  327. X    if (gtot > 0) {
  328. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  329. X            find(c2, tmp->anum);
  330. X            if (x == -999.0) continue;
  331. X            if (x > ymax) ymax = x;
  332. X            if (x < ymin) ymin = x;
  333. X        }
  334. X    } else {
  335. X        for (i = 1; i < gtot; i++) {
  336. X            find(c2, sub1[i]);
  337. X            if (x == -999.0) continue;
  338. X            if (i == 1)
  339. X                ymax = ymin = x;
  340. X            else {
  341. X                if (x > ymax) ymax = x;
  342. X                if (x < ymin) ymin = x;
  343. X            }
  344. X        }
  345. X    }
  346. X
  347. X    /* Now we have min & maxs we have to put a number in
  348. X       each slot on both axes using a scale */
  349. X
  350. X    scale = (xmax - xmin) / 69.0; /* 69 is # of slots in X axis */
  351. X
  352. X    xaxis[1] = xmin;
  353. X    for (i = 2; i < 70; i++)
  354. X        xaxis[i] = xaxis[i-1] + scale;
  355. X
  356. X    scale = (ymax - ymin) / 20.0; /* 20 is # of slots in Y axis */
  357. X
  358. X    yaxis[20] = ymin;
  359. X    for (i = 19; i > 1; i--)
  360. X        yaxis[i] = yaxis[i+1] + scale;
  361. X
  362. X    sprintf(str, "%s (x-axis) vs. %s (y-axis)", gname[numr(c1)], gname[numr(c2)]);
  363. X    mvwaddstr(graph, 0, (40 - (strlen(str) / 2)), str);
  364. X    wrefresh(graph);    /* That is the top graph line */
  365. X    for (i = 20; i > 1; i--) {        /* The y axis line */
  366. X        mvwaddstr(graph, i, 10, "|");
  367. X        wrefresh(graph);
  368. X    }
  369. X    for (i = 11; i < 80; i++) {        /* The x axis line */
  370. X        mvwaddstr(graph, 21, i, "-");
  371. X        wrefresh(graph);
  372. X    }
  373. X    fixup(graph);
  374. X    mvwaddstr(graph, 21, 10, "+");        /* The corner */
  375. X    wrefresh(graph);
  376. X    for (i = 20; i > 1; i -= 5) {        /* Y axis points */
  377. X        if (c2 < 'f' || c2 > 'i')
  378. X            sprintf(str, "%d ->", (int)(yaxis[i]+.5));
  379. X        else
  380. X            sprintf(str, "%4.2f ->", yaxis[i]);
  381. X        mvwaddstr(graph, i, 0, str);
  382. X    }
  383. X    for (i = 1; i < 79; i += 10) {        /* X axis points */
  384. X        if (c1 < 'f' || c1 > 'i')
  385. X            sprintf(str, "^%d", (int)(xaxis[i]+.5));
  386. X        else
  387. X            sprintf(str, "^%4.2f", xaxis[i]);
  388. X        mvwaddstr(graph, 22, i+10, str);
  389. X    }
  390. X    /* The actual find & graph */
  391. X
  392. X    if (gtot > 0) {
  393. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  394. X            find(c1, tmp->anum);
  395. X            if (x == -999.0) continue;
  396. X            if (x < xmin)
  397. X                continue;
  398. X            else if (x < xaxis[2])
  399. X                xspot = 1;
  400. X            else {
  401. X                for (j = 2; j < 70; j++) {
  402. X                    if (x > xaxis[j])
  403. X                        continue;
  404. X                    else
  405. X                        break;
  406. X                }
  407. X                xspot = j - 1;
  408. X                if (x > xmax)
  409. X                    continue;
  410. X            }
  411. X
  412. X            /* Found where it goes on the x, now the y */
  413. X
  414. X            find(c2, tmp->anum);
  415. X            if (x == -999.0) continue;
  416. X            if (x < yaxis[19])
  417. X                yspot = 20;
  418. X            else {
  419. X                for (j = 19; j > 1; j--) {
  420. X                    if (x > yaxis[j])
  421. X                        continue;
  422. X                    else
  423. X                        break;
  424. X                }
  425. X                yspot = j;
  426. X            }
  427. X
  428. X            /* Align and put the dot where X marks the spot */
  429. X
  430. X            mvwaddstr(graph, yspot, xspot+10, "o");
  431. X            wrefresh(graph);
  432. X        }
  433. X    } else {
  434. X        for (i = 1; i < gtot; i++) {
  435. X            find(c1, sub1[i]);
  436. X            if (x == -999.0) continue;
  437. X            if (x < xmin)
  438. X                continue;
  439. X            else if (x < xaxis[2])
  440. X                xspot = 1;
  441. X            else {
  442. X                for (j = 2; j < 70; j++) {
  443. X                    if (x > xaxis[j])
  444. X                        continue;
  445. X                    else
  446. X                        break;
  447. X                }
  448. X                xspot = j - 1;
  449. X                if (x > xmax)
  450. X                    continue;
  451. X            }
  452. X
  453. X            /* Found where it goes on the x, now the y */
  454. X
  455. X            find(c2, sub1[i]);
  456. X            if (x == -999.0) continue;
  457. X            if (x < yaxis[19])
  458. X                yspot = 20;
  459. X            else {
  460. X                for (j = 19; j > 1; j--) {
  461. X                    if (x > yaxis[j])
  462. X                        continue;
  463. X                    else
  464. X                        break;
  465. X                }
  466. X                yspot = j;
  467. X            }
  468. X
  469. X            /* Align and put the dot where X marks the spot */
  470. X
  471. X            mvwaddstr(graph, yspot, xspot+10, "o");
  472. X            wrefresh(graph);
  473. X        }
  474. X    }
  475. X
  476. X    capture(graph, 1, 0);
  477. X    spc();        /* Space to continue? */
  478. X    wclear(graph);
  479. X    wrefresh(graph);
  480. X    return(0);
  481. X}
  482. END_OF_FILE
  483.   if test 7770 -ne `wc -c <'dogph.c'`; then
  484.     echo shar: \"'dogph.c'\" unpacked with wrong size!
  485.   fi
  486.   # end of 'dogph.c'
  487. fi
  488. if test -f 'doregisgph.c' -a "${1}" != "-c" ; then 
  489.   echo shar: Will not clobber existing file \"'doregisgph.c'\"
  490. else
  491.   echo shar: Extracting \"'doregisgph.c'\" \(10517 characters\)
  492.   sed "s/^X//" >'doregisgph.c' <<'END_OF_FILE'
  493. X#ifdef    ReGIS
  494. X
  495. X/*
  496. X * chemtab - a periodic table data base (C) 1990 Jim King
  497. X *           jek5036@ritvax.isc.rit.edu (formerly pulsar@lsrhs)
  498. X *
  499. X * doregisgph.c - Graph better for ReGIS compatible users (OCT 1990)
  500. X */
  501. X
  502. X#include <curses.h>
  503. X#include "windows.h"
  504. X#include <stdio.h>
  505. X#include <math.h>
  506. X#include "variables.h"
  507. X#include "element.h"
  508. X#include "graph.h"
  509. X#include "undefs.h"
  510. X#include <signal.h>
  511. X
  512. Xextern int numr(), stop();
  513. X
  514. X#endif ReGIS
  515. X/*
  516. X * find(ch, en)
  517. X *
  518. X * inputs: char ch; int    enum;
  519. X * returns: floating point integer
  520. X * purpose: replace many switch statements
  521. X */
  522. Xfind(ch, en)
  523. Xint    ch, en;
  524. X{
  525. X    struct elem    *pos;
  526. X    int    i;
  527. X    
  528. X    for (pos = e; en != pos->anum; pos = pos->next) ;
  529. X
  530. X    switch(ch) {
  531. X        case 'a': x = pos->anum; break;
  532. X        case 'b': x = pos->amass; break;
  533. X        case 'c': x = pos->melt; if (x == MEL) x = -999.0;
  534. X              break;
  535. X        case 'd': x = pos->boil; if (x == BOI) x = -999.0;
  536. X              break;
  537. X        case 'e': x = pos->fio; if (x == FIO) x = -999.0;
  538. X              break;
  539. X        case 'f': x = pos->eneg; if (x == ENG) x = -999.0;
  540. X               break;
  541. X        case 'g': x = pos->spht; if (x == SPHT) x = -999.0;
  542. X              break;
  543. X        case 'h': x = pos->dens; if (x == DENS) x = -999.0;
  544. X              break;
  545. X        case 'i': x = pos->arad; if (x == ARD) x = -999.0;
  546. X              break;
  547. X        default:  x = pos->year; if (x == YEA) x = -999.0;
  548. X              break;
  549. X    }
  550. X}
  551. X
  552. X/*
  553. X * doregisgph - no input
  554. X *
  555. X * purpose:    ReGIS graphics support
  556. X */
  557. Xdoregisgph()
  558. X{
  559. X#ifdef    ReGIS
  560. X    char    c, str[80];
  561. X    int    i, j, grid, lastx, lasty, connect, type, firstup;
  562. X    struct elem    *tmp;
  563. X    
  564. X#ifdef    USERSHELL
  565. X    signal(SIGTSTP, SIG_IGN);
  566. X#endif    USERSHELL
  567. X
  568. X    for (i = 0; i < XAXISDEF; i++)
  569. X        xaxis[i] = 0;
  570. X    for (i = 0; i < YAXISDEF; i++)
  571. X        yaxis[i] = 0;
  572. X
  573. X    wclear(graph); wrefresh(graph); clear(); refresh();
  574. X    menu("ReGIS Graphing Module");
  575. X    mvwaddstr(mn, 0, 0, "a] Atomic Number");
  576. X    mvwaddstr(mn, 1, 0, "b] Atomic Mass");
  577. X    mvwaddstr(mn, 2, 0, "c] Melting Temp.");
  578. X    mvwaddstr(mn, 3, 0, "d] Boiling Temp.");
  579. X    mvwaddstr(mn, 4, 0, "e] Ionization Energy");
  580. X    mvwaddstr(mn, 5, 0, "f] Electronegativity");
  581. X    mvwaddstr(mn, 6, 0, "g] Specific Heat");
  582. X    mvwaddstr(mn, 7, 0, "h] Density");
  583. X    mvwaddstr(mn, 8, 0, "i] Atomic Radius");
  584. X    mvwaddstr(mn, 9, 0, "j] Discovery Year");
  585. X    mvwaddstr(mn, 10, 0, "Graphing by this, across the X axis.");
  586. X    mvwaddstr(mn, 13, 0, "*** Due to lack of information at this time, graphs beyond");
  587. X    mvwaddstr(mn, 14, 0, "*** Atomic number 86 may be misleading.  The program is designed");
  588. X    mvwaddstr(mn, 15, 0, "*** to compensate, but nothing is perfect.");
  589. X    mvwaddstr(mn, 16, 0, ">>> PRESS RETURN TO RETURN TO MAIN MENU.");
  590. Xfirst:    mvwaddstr(mn, 11, 0, "Your choice: ");
  591. X    wrefresh(mn);                /* collect their choices */
  592. X    cur = mn; xp = 14; yp = 11;
  593. X    crmode();
  594. X    noecho();
  595. X    c1 = getchar();    /* X axis chc */
  596. X    if (c1 == '?') { help(3); goto first; }
  597. X    if (c1 == '\n') {
  598. X#ifdef    USERSHELL
  599. X        signal(SIGTSTP, stop);
  600. X#endif    USERSHELL
  601. X        wclear(mn);
  602. X        return;
  603. X    }
  604. X    if (c1 < 'a' || c1 > 'j')
  605. X        goto first;
  606. X    for (i = 12; i < 17; i++) {
  607. X        wmove(mn, i, 0); wclrtoeol(mn);
  608. X    }
  609. X
  610. X    find(c1, e->anum);
  611. X    xmax = xmin = x;
  612. X    if (gtot > 0) {
  613. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  614. X            find(c1, tmp->anum);
  615. X            if (x == -999.0) continue;
  616. X            if (x > xmax) xmax = x;
  617. X            if (x < xmin) xmin = x;
  618. X        }
  619. X    } else {
  620. X        for (i = 1; i < gtot; i++) {
  621. X            find(c1, sub1[i]);
  622. X            if (x == -999.0) continue;
  623. X            if (i == 1) xmax = xmin = x;
  624. X            else {
  625. X                if (x > xmax) xmax = x;
  626. X                if (x < xmin) xmin = x;
  627. X            }
  628. X        }
  629. X    }
  630. X
  631. X    mvwaddstr(mn, 10, 0, "If you would rather use the maximum and minimum values of");
  632. X    mvwaddstr(mn, 11, 0, "all the elements, hit RETURN once.");
  633. X    wmove(mn, 12, 0); wprintw(mn, "All the element's values: Minimum %f, Maximum %f", xmin, xmax);
  634. Xrl4:    mvwaddstr(mn, 13, 0, "What range, X Minimum? ");
  635. X    wrefresh(mn);
  636. X    cur = mn; xp = 23; yp = 13;
  637. X    echo(); nocrmode();
  638. X    gets(str);
  639. X    if (str[0] == '?') { help(4); goto rl4; }
  640. X    if (!strlen(str)) {
  641. X        xmin = -999;
  642. X        goto nt;
  643. X    }
  644. X    xmin = atof(str);
  645. X    fixup(mn); fixup(stdscr);
  646. X    mvwaddstr(mn, 13, 0, "What range, X Maximum [RETURN for value above]? ");
  647. X    wrefresh(mn);
  648. X    cur = mn; xp = 49; yp = 13;
  649. X    echo(); nocrmode();
  650. X    gets(str);
  651. X    if (strlen(str))
  652. X        xmax = atof(str);
  653. X    fixup(mn);
  654. X    
  655. Xnt:    wmove(mn, 10, 0); wclrtoeol(mn); wmove(mn, 11, 0); wclrtoeol(mn);
  656. X    mvwaddstr(mn, 10, 0, "Graphing by this, down the Y axis.   ");
  657. Xscnd:    wmove(mn, 12, 0); wclrtoeol(mn); wmove(mn, 13, 0); wclrtoeol(mn);
  658. X    mvwaddstr(mn, 11, 0, "Your choice: ");
  659. X    wrefresh(mn);
  660. X    cur = mn; xp = 13; yp = 11;
  661. X    noecho(); crmode();
  662. X    c2 = wgetch(mn); /* Y axis chc */
  663. X    if (c2 == '?') { help(5); goto scnd; }
  664. X    if (c2 < 'a' || c2 > 'j')
  665. X        goto scnd;
  666. X    noecho();
  667. X
  668. X    /* Here we find the x axis max and min values */
  669. X
  670. X    bot("Calculating the X axis max and min values...");
  671. X
  672. X    if (xmin == -999) {
  673. X        find(c1, e->anum);
  674. X        xmax = xmin = x;
  675. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  676. X            find(c1, tmp->anum);
  677. X            if (x == -999.0) continue;
  678. X            if (x > xmax) xmax = x;
  679. X            if (x < xmin) xmin = x;
  680. X        }
  681. X    }
  682. X
  683. X    /* Here we find the y axis min and max values */
  684. X    bot("Calculating the Y axis max and min values...");
  685. X
  686. X    if (gtot > 0) {
  687. X        find(c2, e->anum);
  688. X        ymax = ymin = x;
  689. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  690. X            find(c2, tmp->anum);
  691. X            if (x == -999.0) continue;
  692. X            if (x > ymax) ymax = x;
  693. X            if (x < ymin) ymin = x;
  694. X        }
  695. X    } else {
  696. X        for (i = 1; i < gtot; i++) {
  697. X            find(c2, sub1[i]);
  698. X            if (x == -999.0) continue;
  699. X            if (i == 1)
  700. X                ymax = ymin = x;
  701. X            else {
  702. X                if (x > ymax) ymax = x;
  703. X                if (x < ymin) ymin = x;
  704. X            }
  705. X        }
  706. X    }
  707. X
  708. X    /* Now we have min & maxs we have to put a number in
  709. X       each slot on both axes using the scale */
  710. X
  711. X    bot("Scaling...");
  712. X    scale = (xmax - xmin) / (double)XAXISDEF;
  713. X    xaxis[1] = xmin;
  714. X    for (i = 2; i < XAXISDEF; i++)
  715. X        xaxis[i] = xaxis[i-1] + scale;
  716. X
  717. X    scale = (ymax - ymin) / (double)YAXISDEF;
  718. X    yaxis[YAXISDEF-1] = ymin;
  719. X    for (i = YAXISDEF-2; i > 1; i--)
  720. X        yaxis[i] = yaxis[i+1] + scale;
  721. X
  722. Xrl6:    noecho(); crmode();
  723. X    mvwaddstr(btm, 0, 0, "Would you like a grid? ");
  724. X    wrefresh(btm);
  725. X    cur = btm; xp = 24; yp = 0;
  726. X    switch(getchar()) {
  727. X        case 'y':
  728. X        case 'Y': grid = 1; break;
  729. X        case '?': help(6); goto rl6;
  730. X        default:  grid = 0; break;
  731. X    }
  732. X    if (c1 < 'c') {
  733. Xrl7:        mvwaddstr(btm, 0, 0, "Would you like the points connected? ");
  734. X        wrefresh(btm);
  735. X        cur = btm; xp = 38; yp = 0;
  736. X        switch(getchar()) {
  737. X            case '?': help(7); goto rl7;
  738. X            case 'y': case 'Y': connect = 1; break;
  739. X            default: connect = 0; break;
  740. X        }
  741. X    } else connect = 0;
  742. Xrl8:    wclear(btm);
  743. X    mvwaddstr(btm, 0, 0, "Would you like dots instead of hashmarks (slower) ");
  744. X    wrefresh(btm);
  745. X    cur = btm; xp = 44; yp = 0;
  746. X    switch(getchar()) {
  747. X        case 'y': case 'Y': type = 1; break;
  748. X        case '?': help(8); goto rl8;
  749. X        default: type = 0; break;
  750. X    }
  751. X#ifdef    LASERPRT
  752. Xrl9:    wclear(btm);
  753. X    mvwaddstr(btm, 0, 0, "Would you like a laser print file of this? ");
  754. X    wrefresh(btm);
  755. X    cur = btm; xp = 40; yp = 0;
  756. X    switch(getchar()) {
  757. X        case 'y': case 'Y': laser = 1; break;
  758. X        case '?': help(19); goto rl9;
  759. X        default: laser = 0; break;
  760. X    }
  761. X    if (laser == 1) {
  762. X        if ((lsr = fopen("laser", "w")) == NULL) {
  763. X            bot("Sorry, the file 'laser' could not be opened for writing.");
  764. X            sleep(2);
  765. X            bot("No laser print document will be made.");
  766. X            sleep(2);
  767. X            bot(" ");
  768. X            laser = 0;
  769. X        } else
  770. X            fprintf(lsr, "\014");
  771. X        bot("A copy will be found in the file 'laser' when you exit chemtab.");
  772. X        sleep(2);
  773. X    }
  774. X#endif    LASERPRT
  775. X    bot("Initializing for graphics...");
  776. X    wclear(mn); wrefresh(mn);
  777. X    wclear(btm); wrefresh(btm);
  778. X    clear(); refresh();
  779. X
  780. X    initregis();
  781. X    regisgoto(450, 10);
  782. X    chcolor(RED_3);
  783. X    text(3, 0, -5, "Chemtab V2.01");
  784. X    regisgoto(400 - (strlen(gname[numr(c1)]) * 10), YMAXDEF + 20);
  785. X    text(2, 0, 0, gname[numr(c1)]);
  786. X    regisgoto(YMINDEF - 46, 200 + (strlen(gname[numr(c2)]) * 10));
  787. X    text(2, 90, 0, gname[numr(c2)]);
  788. X    chcolor(WHT_3);
  789. X    mybox(1, XMINDEF, YMINDEF, XMAXDEF, YMAXDEF);
  790. X    mybox(2, 0, 0, 798, 478);
  791. X    for (i = YAXISDEF-1; i > 1; i -= YAXISDEF/7) {
  792. X        if (c2 < 'f' || c2 > 'i')
  793. X            sprintf(str, "%d -", (int)(yaxis[i]+.5));
  794. X        else if (yaxis[i] > 9.99)
  795. X            sprintf(str, "%2.3f", yaxis[i]);
  796. X        else
  797. X            sprintf(str, "%2.3f", yaxis[i]);
  798. X        chcolor(BLU_3);
  799. X        if (grid) line(XMINDEF, i+YBOUND+1, XMAXDEF, i+YBOUND+1);
  800. X        chcolor(RED_3);
  801. X        regisgoto(XMINDEF-60, i-7+YBOUND);
  802. X        text(1, 0, 5, str);
  803. X    }
  804. X    for (i = 1; i < XAXISDEF; i += XAXISDEF/10) {
  805. X        if (c1 < 'f' || c1 > 'i')
  806. X            sprintf(str, "%d", (int)(xaxis[i]+.5));
  807. X        else
  808. X            sprintf(str, "%4.2f", xaxis[i]);
  809. X        chcolor(BLU_3);
  810. X        if (grid && i < XAXISDEF-20) line(i+XBOUND+1, YMINDEF, i+XBOUND+1, YMAXDEF);
  811. X        chcolor(RED_3);
  812. X        regisgoto(i-6+XBOUND, YMAXDEF+2);
  813. X        text(1, 0, 5, str);
  814. X    }
  815. X
  816. X    firstup++;
  817. X    if (gtot <= 0) {
  818. X        for (tmp = e; tmp->next != NULL; tmp = tmp->next) {
  819. X            find(c1, tmp->anum);
  820. X            if (x == -999.0) continue;
  821. X            if (x < xmin)
  822. X                continue;
  823. X            else if (x < xaxis[2])
  824. X                xspot = 1;
  825. X            else {
  826. X                for (j = 2; j < XAXISDEF; j++) {
  827. X                    if (x > xaxis[j])
  828. X                        continue;
  829. X                    else
  830. X                        break;
  831. X                }
  832. X                xspot = j;
  833. X                if (x > xmax)
  834. X                    continue;
  835. X            }
  836. X
  837. X            /* Found where it goes on the x, now the y */
  838. X
  839. X            find(c2, tmp->anum);    
  840. X            if (x == -999.0) continue;
  841. X            if (x < yaxis[YAXISDEF-1])
  842. X                yspot = YAXISDEF-1;
  843. X            else {
  844. X                for (j = YAXISDEF-2; j > 1; j--) {
  845. X                    if (x > yaxis[j])
  846. X                        continue;
  847. X                    else
  848. X                        break;
  849. X                }
  850. X                yspot = j;
  851. X            }
  852. X            chcolor(YEL_3);
  853. X            if (firstup) { lastx = xspot; lasty = yspot; firstup = 0; }
  854. X            if (connect && i != 1) {
  855. X                chcolor(GRN_3);
  856. X                line(xspot+XBOUND, yspot+YBOUND, lastx+XBOUND, lasty+YBOUND);
  857. X                lastx = xspot; lasty = yspot;
  858. X            }
  859. X            hash(xspot+XBOUND, yspot+YBOUND, type);
  860. X        }
  861. X    } else {
  862. X        for (i = 1; i < gtot; i++) {
  863. X            find(c1, sub1[i]);
  864. X            if (x == -999.0) continue;
  865. X            if (x < xmin)
  866. X                continue;
  867. X            else if (x < xaxis[2])
  868. X                xspot = 1;
  869. X            else {
  870. X                for (j = 2; j < XAXISDEF; j++) {
  871. X                    if (x > xaxis[j])
  872. X                        continue;
  873. X                    else
  874. X                        break;
  875. X                }
  876. X                xspot = j;
  877. X                if (x > xmax)
  878. X                    continue;
  879. X            }
  880. X
  881. X            /* Found where it goes on the x, now the y */
  882. X
  883. X            find(c2, sub1[i]);
  884. X            if (x == -999.0) continue;
  885. X            if (x < yaxis[YAXISDEF-1])
  886. X                yspot = YAXISDEF-1;
  887. X            else {
  888. X                for (j = YAXISDEF; j > 1; j--) {
  889. X                    if (x > yaxis[j])
  890. X                        continue;
  891. X                    else
  892. X                        break;
  893. X                }
  894. X                yspot = j;
  895. X            }
  896. X            chcolor(YEL_3);
  897. X            if (i == 1) lastx = xspot, lasty = yspot;
  898. X            if (connect && i != 1) {
  899. X                chcolor(GRN_3);
  900. X                line(xspot+XBOUND, yspot+YBOUND, lastx+XBOUND, lasty+YBOUND);
  901. X                lastx = xspot; lasty = yspot;
  902. X            }
  903. X            hash(xspot+XBOUND, yspot+YBOUND, type);
  904. X        }
  905. X    }
  906. X    regispc();
  907. X    endregis();
  908. X#ifdef    LASERPRT
  909. X    if (laser)
  910. X        fclose(lsr);
  911. X#endif    LASERPRT
  912. X    clear(); refresh();
  913. X    wclear(graph); wrefresh(graph);
  914. X#ifdef    USERSHELL
  915. X    signal(SIGTSTP, stop);
  916. X#endif    USERSHELL
  917. X    return(0);
  918. X#endif ReGIS
  919. X}
  920. END_OF_FILE
  921.   if test 10517 -ne `wc -c <'doregisgph.c'`; then
  922.     echo shar: \"'doregisgph.c'\" unpacked with wrong size!
  923.   fi
  924.   # end of 'doregisgph.c'
  925. fi
  926. if test -f 'elist' -a "${1}" != "-c" ; then 
  927.   echo shar: Will not clobber existing file \"'elist'\"
  928. else
  929.   echo shar: Extracting \"'elist'\" \(8311 characters\)
  930.   sed "s/^X//" >'elist' <<'END_OF_FILE'
  931. XName         Sy   Z    MASS FM R V MELT BOIL FIO YEAR  ENG SPHT  DENS ARD
  932. X
  933. Xactinium     Ac  89 227.028  1 7 9 1050 3200 159 1899 -1.5  -1.5 10.1 -1.5
  934. Xaluminum     Al  13  26.982 13 3 3  660 2467 138 1827  1.5 0.215 2.70 1.43
  935. Xamericium    Am  95 243.000  7 9 9  994 2607 138 1944 -1.5  -1.5 11.7 -1.5
  936. Xantimony     Sb  51 121.753 15 5 5  631 1750 199 1700  1.9 0.049 6.69 1.41
  937. Xargon         Ar  18  39.948 18 3 0 -189 -186 362 1894 -1.5 0.124 1.40 1.74
  938. Xarsenic      As  33  74.922 15 4 5  817  613 226 1649  2.0 0.078 5.73 1.21
  939. Xastatine     At  85 210.000 17 6 7  302  337  -1 1940  2.2  -1.5 -1.5 1.40
  940. Xbarium       Ba  56 137.327  2 6 2  725 1640 120 1774  0.9 0.046 3.50 2.17
  941. Xberkelium    Bk  97 247.000  9 9 3 -273 -273  -1 1949 -1.5  -1.5 -1.5 -1.5
  942. Xberyllium    Be   4   9.012  2 2 2  127 2970 214 1798  1.5 0.436 1.85 1.12
  943. Xbismuth      Bi  83 208.980 15 6 5  271 1560 168 1753  1.9 0.029 9.80 1.46
  944. Xboron         B    5  10.811 13 2 3 2079 2550 191 1808  2.0 0.245 2.34 0.88
  945. Xbromine      Br  35  79.904 17 4 7   -7   59 272 1826  2.8 0.113 3.12 1.14
  946. Xcadminium    Cd  48 112.411 12 5 2  321  765 207 1817  1.7 0.055 8.02 1.48
  947. Xcalcium         Ca  20  40.078  2 4 2  839 1484 141 1808  1.0 0.156 1.54 1.97
  948. Xcalifornium  Cf  98 251.000 10 9 9 -273 -273  -1 1950 -1.5  -1.5 -1.5 -1.5
  949. Xcarbon         C    6  12.011 14 2 4 3550 4827 259   -1  2.5 0.170 2.25 0.77
  950. Xcerium       Ce  58 140.115  2 8 9  798 3257 126 1803  1.1 0.049 6.70 -1.5
  951. Xcesium       Cs  55 132.905  1 6 1   28  669  90 1860  0.7 0.057 1.84 2.62
  952. Xchlorine     Cl  17  35.452 17 3 7 -101  -35 298 1774  3.0 0.114 1.37 0.99
  953. Xchromium     Cr  24  51.996  6 4 9 1857 2672 156 1798  1.6 0.107 7.18 1.25
  954. Xcobalt         Co  27  58.933  9 4 9 1495 2870 181 1735  1.8 0.109 8.90 1.25
  955. Xcopper         Cu  29  63.546 11 4 9 1083 2567 178   -1  1.9 0.092 8.96 1.20
  956. Xcurium       Cm  96 247.000  8 9 3 1340 -273  -1 1944 -1.5  -1.5 -1.5 -1.5
  957. Xdysprosium   Dy  66 162.503 10 8 3 1409 2335 136 1886  1.2 0.041 8.50 -1.5
  958. Xeinsteinum   Es  99 254.000 11 9 9 -273 -273  -1 1952 -1.5  -1.5 -1.5 -1.5
  959. Xerbium       Er  68 167.263 12 8 3 1522 2510 140 1842  1.2 0.040 9.10 -1.5
  960. Xeuropium     Eu  63 151.965  7 8 2  822 1597 130 1890  1.2 0.042 5.30 -1.5
  961. Xfermium      Fm 100 257.000 12 9 9 -273 -273  -1 1952 -1.5  -1.5 -1.5 -1.5
  962. Xfluorine     F    9  18.998 17 2 7 -220 -188 401 1886  4.0 0.197 1.11 0.64
  963. Xfrancium     Fr  87 223.000  1 7 1   27  677  -1 1939  0.7  -1.5 -1.5 2.70
  964. Xgadolinium   Gd  64 157.253  8 8 3 1311 3233 141 1880  1.1 0.055 7.90 -1.5
  965. Xgallium      Ga  31  69.723 13 4 3   30 2403 138 1875  1.6 0.089 5.91 1.22
  966. Xgermanium    Ge  32  72.612 14 4 4  937 2830 182 1886  1.8 0.077 5.32 1.22
  967. Xgold         Au  79 196.967 11 6 1 1064 3080 212   -1  2.4 0.031 19.3 1.50
  968. Xhafnium      Hf  72 178.492  4 6 4 2227 4602 161 1923  1.3 0.035 13.1 1.65
  969. Xhelium         He   2   4.003 18 1 0 -272 -269 563 1868 -1.5 1.240 0.18 0.93
  970. Xholmium      Ho  67 164.930 11 8 3 1470 2720 138 1878  1.1 0.039 8.80 -1.5
  971. Xhydrogen     H    1   1.008  1 1 1 -259 -253 313 1766  2.2 3.410 0.09 0.30
  972. Xindium       In  49 114.821 13 5 3  157 2080 133 1924  1.7 0.056 7.30 1.44
  973. Xiodine       I   53 126.904 17 5 7  114  184 240 1811  2.5 0.010 4.94 1.33
  974. Xiridium      Ir  77 192.223  9 6 3 2410 4130 209 1803  2.2 0.032 22.5 1.48
  975. Xiron         Fe  26  55.847  8 4 9 1535 2750 181   -1  1.8 0.106 7.87 1.26
  976. Xkrypton      Kr  36  83.801 18 4 0 -157 -152 322 1898 -1.5 0.059 2.16 1.89
  977. Xlanthanium   La  57 138.906  1 6 9  920 3454 128 1839  1.1 0.047 6.20 1.69
  978. Xlawrencium   Lr 103 260.000 15 9 3 -273 -273  -1 1961 -1.5  -1.5 -1.5 -1.5
  979. Xlead         Pb  82 207.210 14 6 4  328 1720 171   -1  1.8 0.038 11.4 1.75
  980. Xlithium         Li   3   6.941  1 2 1  181 1342 124 1817  1.0 0.834 0.53 1.52
  981. Xlutetium     Lu  71 174.967 15 8 3 1656 3315 125 1907  1.2 0.037 9.80 -1.5
  982. Xmagnesium    Mg  12  24.305  2 3 2  649 1090 176 1755  1.2 0.245 1.74 1.60
  983. Xmanganese    Mn  25  54.938  7 4 9 1244 1962 171 1774  1.5 0.114 7.21 1.29
  984. Xmendelevium  Md 101 258.000 13 9 3 -273 -273  -1 1955 -1.5  -1.5 -1.5 -1.5
  985. Xmercury      Hg  80 200.593 12 6 1  -39  357 240   -1  1.9 0.033 13.6 1.49
  986. Xmolybdenum   Mo  42  95.941  6 5 6 2617 4612 163 1778  1.8 0.060 9.35 1.47
  987. Xneodymium    Nd  60 144.243  4 8 3 1010 3127 126 1841  1.1 0.049 7.00 -1.5
  988. Xneon         Ne  10  20.180 18 2 8 -249 -246 496 1898 -1.5 0.246 1.21 1.31
  989. Xneptunium    Np  93 237.048  5 9 4  640 3902  -1 1940 -1.5  -1.5 19.5 -1.5
  990. Xnickel         Ni  28  58.691 10 4 9 1453 2732 176 1751  1.8 0.106 8.90 1.24
  991. Xniobium      Nb  41  92.906  5 5 5 2468 4742 158 1801  1.6 0.064 7.83 1.48
  992. Xnitrogen     N    7  14.007 15 2 5 -210 -196 334 1772  3.0 0.249 0.81 0.70
  993. Xnobelium     No 102 259.000 14 9 4 -273 -273  -1 1958 -1.5  -1.5 -1.5 -1.5
  994. Xosmium       Os  76 190.210  8 6 8 3045 5027 200 1803  2.2 0.031 22.6 1.52
  995. Xoxygen         O    8  15.999 16 2 6 -218 -183 313 1774  3.5 0.219 1.14 0.66
  996. Xpalladium    Pd  46 106.421 10 5 4 1554 3140 192 1803  2.2 0.058 10.7 1.44
  997. Xphosphorous  P   15  30.974 15 3 5   44  280 350 1669  2.1 0.181 0.82 1.10
  998. Xplatinum     Pt  78 195.083 10 6 4 1772 3827 207 1735  2.2 0.031 21.4 1.45
  999. Xplutonium    Pu  94 244.000  6 9 5  641 3232 133 1940 -1.5  -1.5 19.5 -1.5
  1000. Xpolonium     Po  84 209.000 16 6 6  254  962 194 1898  2.0 0.030 9.20 1.40
  1001. Xpotassium    K   19  39.098  1 4 1   64  774 100 1807  0.8 0.180 0.86 2.31
  1002. Xpraeseodymium Pr  59 140.908  3 8 3  931 3212 125 1841 1.2 0.046 6.80 -1.5
  1003. Xpromethium   Pm  61 145.000  5 8 3 1080 2460 128 1902  1.1 0.044 -1.5 -1.5
  1004. Xprotactinium Pa  91 231.035  3 9 4 1600 -273  -1 1913 -1.5 0.029 15.4 -1.5
  1005. Xradium       Ra  88 226.025  2 7 2  700 1140 121 1898  0.9 0.028 -1.5 2.20
  1006. Xradon        Rn  86 222.000 18 6 0  -71  -62 247 1908 -1.5 0.022 -1.5 2.14
  1007. Xrhenium      Re  75 186.207  7 6 7 3180 5627 181 1925  1.9 0.033 21.0 1.56
  1008. Xrhodium      Rh  45 102.905  9 5 6 1966 3727 172 1803  2.2 0.058 11.1 1.45
  1009. Xrubidium     Rb  37  85.468  1 5 1   39  688  96 1861  0.8 0.086 1.53 2.44
  1010. Xruthenium    Ru  44 101.072  8 5 8 2310 3900 170 1827  2.2 0.057 10.9 1.46
  1011. Xsamarium     Sm  62 150.363  6 8 2 1072 1778 129 1879  1.2 0.043 7.50 -1.5
  1012. Xscandium     Sc  21  44.956  3 4 9 1539 2832 150 1879  1.3 0.133 2.99 1.60
  1013. Xselenium     Se  34  78.963 16 4 6  217  685 224 1818  2.4 0.077 4.79 1.17
  1014. Xsilicon         Si  14  28.086 14 3 4 1410 2355 187 1824  1.8 0.169 2.33 1.17
  1015. Xsilver       Ag  47 107.868 11 5 2  962 2212 174   -1  1.9 0.057 9.32 1.53
  1016. Xsodium         Na  11  22.990  1 3 1   98  883 118 1807  0.9 0.292 0.97 1.86
  1017. Xstrontium    Sr  38  87.621  2 5 2  769 1384 131 1790  1.0 0.072 2.63 2.15
  1018. Xsulfur         S   16  32.066 16 3 6  113  445 238   -1  2.5 0.175 2.06 1.04
  1019. Xtantalum     Ta  73 180.948  5 6 5 2996 5425 181 1844  1.5 0.033 16.6 1.62
  1020. Xtechnetium   Tc  43  98.000  7 5 7 2172 4877 167 1925  1.9 0.058 11.5 1.47
  1021. Xtellurium    Te  52 127.603 16 5 6  450  990 207 1782  2.1 0.048 5.75 1.37
  1022. Xterbium      Tb  65 158.925  9 8 3 1360 3041 135 1843  1.2 0.044 8.30 -1.5
  1023. Xthallium     Tl  81 204.383 13 6 3  304 1457 140 1861  1.8 0.031 11.9 1.48
  1024. Xthorium      Th  90 232.038  2 9 4 1750 4790 139 1828 -1.5 0.027 11.7 -1.5
  1025. Xthullium     Tm  69 168.934 13 8 2 1545 1727 142 1879  1.2 0.038 9.10 -1.5
  1026. Xtin          Sn  50 118.710 14 5 4  232 2270 169   -1  1.8 0.052 6.98 1.40
  1027. Xtitanium     Ti  22  47.883  4 4 9 1660 3287 157 1791  1.4 0.125 4.54 1.46
  1028. Xtungsten     W   74 183.853  6 6 6 3410 5660 184 1779  1.7 0.032 19.3 1.60
  1029. Xunnilennium  Une 109 266.000  9 7 9 -273 -273  -1 1982 -1.5  -1.5 -1.5 -1.5
  1030. Xunnilhexium  Unh 106 263.000  6 7 9 -273 -273  -1 1974 -1.5  -1.5 -1.5 -1.5
  1031. Xunniloctium  Uno 108 265.000  8 7 9 -273 -273  -1 1980 -1.5  -1.5 -1.5 -1.5
  1032. Xunnilpentium Unp 105 262.000  5 7 9 -273 -273  -1 1967 -1.5  -1.5 -1.5 -1.5
  1033. Xunnilquadium Unq 104 261.000  4 7 9 -273 -273  -1 1964 -1.5  -1.5 -1.5 -1.5
  1034. Xunnilseptium Uns 107 262.000  7 7 9 -273 -273  -1 1976 -1.5  -1.5 -1.5 -1.5
  1035. Xunununium    Unu 110 272.000 10 7 9 -273 -273  -1 1987 -1.5  -1.5 -1.5 -1.5
  1036. Xuranium      U   92 238.028  4 9 6 1132 3818  -1 1789 -1.5 0.028 19.1 -1.5
  1037. Xvanadium     V   23  50.941  5 4 9 1890 3380 155 1831  1.6 0.116 6.09 1.31
  1038. Xxenon        Xe  54 131.292 18 5 0 -112 -107 279 1898 -1.5 0.038 -1.5 2.09
  1039. Xytterbium    Yb  70 173.043 14 8 2  824 1193 144 1878  1.2 0.035 7.00 -1.5
  1040. Xyttrium      Y   39  88.906  3 5 3 1523 3337 147 1794  1.2 0.068 4.47 1.62
  1041. Xzinc         Zn  30  65.392 12 4 9  420  907 216 1746  1.6 0.093 7.13 1.33
  1042. Xzirconium    Zr  40  91.224  4 5 4 1852 4377 157 1824  1.4 0.067 5.80 1.48
  1043. END_OF_FILE
  1044.   if test 8311 -ne `wc -c <'elist'`; then
  1045.     echo shar: \"'elist'\" unpacked with wrong size!
  1046.   fi
  1047.   # end of 'elist'
  1048. fi
  1049. if test -f 'esort.c' -a "${1}" != "-c" ; then 
  1050.   echo shar: Will not clobber existing file \"'esort.c'\"
  1051. else
  1052.   echo shar: Extracting \"'esort.c'\" \(3526 characters\)
  1053.   sed "s/^X//" >'esort.c' <<'END_OF_FILE'
  1054. X
  1055. X/*
  1056. X * chemtab - a periodic table data base (C) 1990 Jim King (pulsar@lsrhs)
  1057. X *
  1058. X * esort.c    Takes the changed values to look for and sifts to sub1
  1059. X */
  1060. X
  1061. X#include "element.h"
  1062. X#include "undefs.h"
  1063. X#include "variables.h"
  1064. X#include "tune.h"
  1065. X#include <curses.h>
  1066. X#include "windows.h"
  1067. X
  1068. X
  1069. Xint    sift[3][120],    /* Enough spaces to carry all the elements through
  1070. X               the sifting process 3 times. */
  1071. X    sftc[3];    /* number telling the amount of elements in sift[x] */
  1072. Xint    tmp[120],    /* A place to put compared elements from 1&2 & 2&3 */
  1073. X    tc;        /* The temp[x] counter */
  1074. X
  1075. X/*
  1076. X * esort() - no input
  1077. X *
  1078. X * purpose:    Take the selecting characteristics from dosort[x] which are
  1079. X *        defined in schar() and sift the elements through them, then
  1080. X *        see what's left and store it away.
  1081. X */
  1082. Xesort()
  1083. X{
  1084. X    struct    elem    *tempo;
  1085. X    int    i, j, k;        /* loops */
  1086. X
  1087. X    x = 0.0;            /* floating integer for cmp */
  1088. X
  1089. X    if (dosort[0].wch == 0)            /* No chars to sort */
  1090. X        return(1);
  1091. X
  1092. X    tc = gtot = 0;                /* Reset counter */
  1093. X    for (i = 0; i < 120; i++) {
  1094. X        sub1[i] = 0;            /* Clear the olds */
  1095. X        sift[0][i] = sift[1][i] = sift[2][i] = 0;
  1096. X        tmp[i] = 0;
  1097. X    }
  1098. X    sftc[0] = sftc[1] = sftc[2] = 0;
  1099. X
  1100. X    for (i = 0; i < 3; i++) {
  1101. X        if (dosort[i].wch != 0) {    /* Sort on this */
  1102. X            for (tempo = e; tempo != NULL; tempo = tempo->next) {
  1103. X                switch(dosort[i].wch) {
  1104. X                    case 1: x = tempo->anum;  break;
  1105. X                    case 2: x = tempo->amass; break;
  1106. X                    case 3: x = tempo->fam;   break;
  1107. X                    case 4: x = tempo->row;   break;
  1108. X                    case 5: x = tempo->val;   break;
  1109. X                    case 6: x = tempo->melt;  break;
  1110. X                    case 7: x = tempo->boil;  break;
  1111. X                    case 8: x = tempo->fio;   break;
  1112. X                    case 9: x = tempo->year;  break;
  1113. X                    case 10: x = tempo->eneg; break;
  1114. X                    case 11: x = tempo->spht; break;
  1115. X                    case 12: x = tempo->dens; break;
  1116. X                    case 13: x = tempo->arad; break;
  1117. X                    default:              break;
  1118. X                }
  1119. X                if ((x > dosort[i].amt && dosort[i].sgn == GREATER) ||
  1120. X                    (x < dosort[i].amt && dosort[i].sgn == LESS) ||
  1121. X                    (x == dosort[i].amt && dosort[i].sgn == EQUAL) ||
  1122. X                    (x >= dosort[i].amt - closev[dosort[i].wch] && x <= dosort[i].amt + closev[dosort[i].wch] && dosort[i].sgn == CLOSE)) {
  1123. X                    if (!((dosort[i].wch == 5 && x == VAL) ||
  1124. X                        (dosort[i].wch == 6 && x == MEL) ||
  1125. X                        (dosort[i].wch == 7 && x == BOI) ||
  1126. X                        (dosort[i].wch == 8 && x == FIO) ||
  1127. X                        (dosort[i].wch == 10 && x == ENG) ||
  1128. X                        (dosort[i].wch == 11 && x == SPHT) ||
  1129. X                        (dosort[i].wch == 12 && x == DENS) ||
  1130. X                        (dosort[i].wch == 13 && x == ARD))) {
  1131. X                        sftc[i]++;
  1132. X                        sift[i][sftc[i]] = tempo->anum;
  1133. X                        }
  1134. X                }
  1135. X            }
  1136. X        }
  1137. X    }
  1138. X                    /* Now sift each to other */
  1139. X                    /* Compare 1 and 2 into tmp[] */
  1140. X    if (dosort[1].wch == 0) {    /* Only 1 sort */
  1141. X        for (i = 1; i < 120; i++) /* Copy sift[0] into sub1 */
  1142. X            sub1[i] = sift[0][i];
  1143. X        goto end;
  1144. X    }
  1145. X    for (j = 1; j < 120; j++) {    /* Compare sift[1] and sift[0] */
  1146. X        if (sift[0][j] != 0) {    /* If something to compare */
  1147. X            for (k = 1; k < 120; k++) {
  1148. X                if (sift[0][j] == sift[1][k]) {
  1149. X                    tc++;    /* Match */
  1150. X                    tmp[tc] = sift[0][j];
  1151. X                }
  1152. X            }
  1153. X        }
  1154. X    }
  1155. X    if (dosort[2].wch == 0) {    /* Only 2 sorts */
  1156. X        for (i = 1; i < 120; i++) /* Copy tmp into sub1 */
  1157. X            sub1[i] = tmp[i];
  1158. X        goto end;
  1159. X    }
  1160. X                    /* Now sift tmp[] with sift[2] */
  1161. X    for (i = 1; i < 120; i++) {
  1162. X        if (tmp[i] != 0) {
  1163. X            for (j = 1; j < 120; j++) {
  1164. X                if (tmp[i] == sift[2][j]) {
  1165. X                    ++gtot;
  1166. X                    sub1[gtot] = tmp[i]; /* Match */
  1167. X                }
  1168. X            }
  1169. X        }
  1170. X    }
  1171. X    goto rend;
  1172. Xend:    for (i = 1; i < 120; i++) {
  1173. X        if (sub1[i] != 0)
  1174. X            gtot++;
  1175. X    }
  1176. Xrend:    /* This is the end! */
  1177. X    tc = 0;
  1178. X    return(0);
  1179. X}
  1180. END_OF_FILE
  1181.   if test 3526 -ne `wc -c <'esort.c'`; then
  1182.     echo shar: \"'esort.c'\" unpacked with wrong size!
  1183.   fi
  1184.   # end of 'esort.c'
  1185. fi
  1186. if test -f 'looke.c' -a "${1}" != "-c" ; then 
  1187.   echo shar: Will not clobber existing file \"'looke.c'\"
  1188. else
  1189.   echo shar: Extracting \"'looke.c'\" \(6499 characters\)
  1190.   sed "s/^X//" >'looke.c' <<'END_OF_FILE'
  1191. X/*
  1192. X * chemtab - a periodic table data base (C) 1990 Jim King pulsar@lsrhs
  1193. X *
  1194. X * looke.c - look for an element, then print known stats
  1195. X */
  1196. X
  1197. X#include <curses.h>
  1198. X#include <stdio.h>
  1199. X#include <ctype.h>
  1200. X#include "element.h"
  1201. X#include "variables.h"
  1202. X#include "tune.h"
  1203. X#include "windows.h"
  1204. X#include "undefs.h"
  1205. X
  1206. X/*
  1207. X * matchstr(str)
  1208. X * input: string
  1209. X * return: int (number if found, 0 if not, -1 if ambiguous)
  1210. X * purpose: match chemical names
  1211. X */
  1212. Xint    matchstr(str)
  1213. Xchar    *str;
  1214. X{
  1215. X    int    last, len, count = 0;
  1216. X    struct    elem    *tmp;
  1217. X
  1218. X    len = strlen(str);
  1219. X
  1220. X    for (tmp = e; tmp != NULL; tmp = tmp->next) {
  1221. X        if (!strncmp(str, tmp->name, len)) {
  1222. X            last = tmp->anum;
  1223. X            count++;
  1224. X        }
  1225. X    }
  1226. X    
  1227. X    if (!count) return(0);
  1228. X    else if (count > 1) return(-1);
  1229. X    else return(last);
  1230. X}
  1231. X
  1232. X/*
  1233. X * getlows(str)
  1234. X *    input: none
  1235. X *    output: string
  1236. X *    purpose: get a lowercase string
  1237. X */
  1238. Xchar *getlows()
  1239. X{
  1240. X    char    input[80];
  1241. X    int    i;
  1242. X
  1243. X    gets(input);
  1244. X    for (i = 0; i < strlen(input); i++)
  1245. X        input[i] = tolower(input[i]);
  1246. X
  1247. X    return(input);
  1248. X}
  1249. X
  1250. X/*
  1251. X * disp(l)
  1252. X *    input:    l - int - referring to atomic number of elem. to display
  1253. X *    output: curses only
  1254. X *
  1255. X * purpose:    separate the displaying from the rest of the subroutine
  1256. X */
  1257. Xdisp(l)
  1258. Xint    l;
  1259. X{
  1260. X    struct    elem    *tmp;
  1261. X    int    i;
  1262. X
  1263. X    for (tmp = e; l != tmp->anum; tmp = tmp->next) ;
  1264. X
  1265. X    wclear(mn); wrefresh(mn);
  1266. X    wclear(graph);
  1267. X    wmove(graph, 0, 0); wprintw(graph, "Atomic Name: %s", tmp->name);
  1268. X    wmove(graph, 1, 0); wprintw(graph, "Atomic Symbol: %s", tmp->sym);
  1269. X    wmove(graph, 2, 0); wprintw(graph, "Atomic Number: %d", tmp->anum);
  1270. X    wmove(graph, 3, 0); wprintw(graph, "Atomic Mass: %3.3f a.m.u.", tmp->amass);
  1271. X
  1272. X    if (tmp->melt == MEL)
  1273. X        mvwaddstr(graph, 5, 0, "Melting Temp: NOT AVAILABLE");
  1274. X    else {
  1275. X        wmove(graph, 5, 0); wprintw(graph, "Melting Temp: %d Celcius (%4.0f Fahrenheit, %d Kelvin)", tmp->melt, ((float)tmp->melt * (9.0 / 5.0) + 32.0), tmp->melt + 273);
  1276. X    }
  1277. X    if (tmp->boil == BOI)
  1278. X        mvwaddstr(graph, 6, 0, "Boiling Temp: NOT AVAILABLE");
  1279. X
  1280. X    else {
  1281. X        wmove(graph, 6, 0); wprintw(graph, "Boiling Temp: %d Celcius (%4.0f Fahrenheit, %d Kelvin)", tmp->boil, ((float)tmp->boil * (9.0 / 5.0) + 32.0), tmp->boil + 273);
  1282. X    }
  1283. X    if (tmp->spht == SPHT)
  1284. X        mvwaddstr(graph, 8, 0, "Specific Heat: NOT AVAILABLE");
  1285. X    else {
  1286. X        wmove(graph, 8, 0); wprintw(graph, "Specific Heat: %1.3f Calories/gram-Celcius", tmp->spht);
  1287. X    }
  1288. X    if (tmp->dens == DENS)
  1289. X        mvwaddstr(graph, 9, 0, "Density: NOT AVAILABLE");
  1290. X    else {
  1291. X        wmove(graph, 9, 0); wprintw(graph, "Density: %2.2f gram/cm cubed", tmp->dens);
  1292. X    }
  1293. X    if (tmp->arad == ARD)
  1294. X        mvwaddstr(graph, 10, 0, "Atomic Radius: NOT AVAILABLE");
  1295. X    else {
  1296. X        wmove(graph, 10, 0); wprintw(graph, "Atomic Radius: %1.2f Angstroms", tmp->arad);
  1297. X    }
  1298. X    if (tmp->eneg == ENG)
  1299. X        mvwaddstr(graph, 11, 0, "Electronegativity: NOT AVAILABLE");
  1300. X    else {
  1301. X        wmove(graph, 11, 0); wprintw(graph, "Electronegativity: %1.1f", tmp->eneg);
  1302. X    }
  1303. X    if (tmp->year == YEA)
  1304. X        mvwaddstr(graph, 12, 0, "Discovery Year: ANCIENT, B.C.");
  1305. X    else {
  1306. X        wmove(graph, 12, 0); wprintw(graph, "Discovery Year: %d A.D.", tmp->year);
  1307. X    }
  1308. X    mvwaddstr(graph, 14, 0, "Family: ");
  1309. X    switch(tmp->fam) {
  1310. X        case 1: wprintw(graph, "IA (1)"); break;
  1311. X        case 2: wprintw(graph, "IIA (2)"); break;
  1312. X        case 3: wprintw(graph, "IB (3)"); break;
  1313. X        case 4: wprintw(graph, "IIB (4)"); break;
  1314. X        case 5: wprintw(graph, "IIIB (5)"); break;
  1315. X        case 6: wprintw(graph, "IVB (6)"); break;
  1316. X        case 7: wprintw(graph, "VB (7)"); break;
  1317. X        case 8: wprintw(graph, "VIB (8)"); break;
  1318. X        case 9: wprintw(graph, "VIIB (9)"); break;
  1319. X        case 10: wprintw(graph, "VIIIB (10)"); break;
  1320. X        case 11: wprintw(graph, "VIXB (11)"); break;
  1321. X        case 12: wprintw(graph, "VXB (12)"); break;
  1322. X        case 13: wprintw(graph, "IIIA (13)"); break;
  1323. X        case 14: wprintw(graph, "IVA (14)"); break;
  1324. X        case 15: wprintw(graph, "VA (15)"); break;
  1325. X        case 16: wprintw(graph, "VIA (16)"); break;
  1326. X        case 17: wprintw(graph, "VIIA (17)"); break;
  1327. X        case 18: wprintw(graph, "VIIIA (18)"); break;
  1328. X        default: break;
  1329. X    }
  1330. X    wmove(graph, 15, 0);
  1331. X    wprintw(graph, "Row: %d\n", tmp->row);
  1332. X    wrefresh(graph);
  1333. X    capture(graph, 0, 0);
  1334. X    spc();    /* space to continue? */
  1335. X}
  1336. X    
  1337. Xlooke()
  1338. X{
  1339. X    struct    elem    *tmp;
  1340. X    char    *strn,                /* Random input string */
  1341. X        srch[80],            /* String comparison */
  1342. X        c = '5';            /* choice input */
  1343. X    int    i, elk;
  1344. X
  1345. X    noecho(); crmode();
  1346. X    wclear(mn); wrefresh(mn);
  1347. X    wclear(srt); wrefresh(srt);
  1348. X    clear(); refresh();
  1349. X
  1350. X    menu("View Elemental Information");
  1351. X    mvwaddstr(mn, 2, 0, "Look for element by:");
  1352. X    mvwaddstr(mn, 4, 0, "1] Atomic Name");
  1353. X    mvwaddstr(mn, 5, 0, "2] Atomic Number");
  1354. X    mvwaddstr(mn, 6, 0, "3] Atomic Symbol");
  1355. X    mvwaddstr(mn, 7, 0, "4] Return to Main Menu");
  1356. Xl9:    mvwaddstr(mn, 9, 0, "Your Choice? ");
  1357. X    wrefresh(mn);
  1358. X    cur = mn; xp = 14; yp = 9;
  1359. X    noecho();
  1360. X    crmode();
  1361. Xgo:    c = wgetch(mn);
  1362. X    if (c == '?') { help(9); goto l9; }
  1363. X    if (c < '1' || c > '4') goto go;
  1364. X
  1365. X    if (c == '4') {
  1366. X        wprintw(mn, "Return to Main Menu.");
  1367. X        wrefresh(mn);
  1368. X        wclear(mn);
  1369. X        return(0);
  1370. X    }
  1371. X    
  1372. X    if (c == '1') {        /* look by name */
  1373. X        wprintw(mn, "Look by Name (type in full or part of an element name)");
  1374. X        wclrtoeol(mn);
  1375. Xl10:        mvwaddstr(mn, 11, 0, "Name of Element: ");
  1376. X        wrefresh(mn);
  1377. X        cur = mn; xp = 17; yp = 11;
  1378. X        echo();
  1379. X        nocrmode();
  1380. X        strcpy(srch, getlows());
  1381. X        if (srch[0] == '?') { help(10); goto l10; }
  1382. X    }
  1383. X
  1384. X    if (c == '2') {        /* look by number */
  1385. X        wprintw(mn, "Look by Number");
  1386. X        wclrtoeol(mn);
  1387. Xl11:        mvwaddstr(mn, 11, 0, "Atomic Number:   ");
  1388. X        wrefresh(mn);
  1389. X        cur = mn; xp = 17; yp = 11;
  1390. X        echo();
  1391. X        nocrmode();
  1392. X        gets(srch);
  1393. X        if (srch[0] == '?') { help(11); goto l11; }
  1394. X        if (atoi(srch) < 1) looke();
  1395. X    }
  1396. X
  1397. X    if (c == '3') {        /* look by symbol */
  1398. X        wprintw(mn, "Look by Symbol");
  1399. X        wclrtoeol(mn);
  1400. Xl12:        mvwaddstr(mn, 11, 0, "Atomic Symbol:   ");
  1401. X        wrefresh(mn);
  1402. X        cur = mn; xp = 17; yp = 11;
  1403. X        echo();
  1404. X        nocrmode();
  1405. X        gets(srch);
  1406. X        if (srch[0] == '?') { help(12); goto l12; }
  1407. X    }
  1408. X    
  1409. X    for (tmp = e; tmp != NULL; tmp = tmp->next) {
  1410. X        switch(c) {        /* then display it */
  1411. X            case '1':
  1412. X                elk = matchstr(srch);
  1413. X                switch(elk) {
  1414. X                    case -1:
  1415. X                        if (c == '1')
  1416. X                            mvwaddstr(mn, 11, 0, "Element name is ambiguous.");
  1417. X                        else
  1418. X                            mvwaddstr(mn, 11, 0, "Element symbol is ambiguous.");
  1419. X                        wrefresh(mn);
  1420. X                        sleep(2);
  1421. X                        goto nd;
  1422. X                    case 0: break;
  1423. X                    default: disp(elk); goto nd;
  1424. X                }
  1425. X                break;
  1426. X            case '3':
  1427. X                if (strcmp(srch, tmp->sym) == 0) {
  1428. X                    disp(tmp->anum); goto nd;
  1429. X                } else break;
  1430. X            default:
  1431. X                if (atoi(srch) == tmp->anum) {
  1432. X                    disp(tmp->anum); goto nd;
  1433. X                } else
  1434. X                    break;
  1435. X        }
  1436. X    }
  1437. X    mvwaddstr(mn, 10, 0, "No such element:");
  1438. X    wrefresh(mn);
  1439. X    sleep(2);
  1440. Xnd:    wclear(graph); wrefresh(graph);
  1441. X    wclear(mn); wrefresh(mn);
  1442. X    looke();
  1443. X}
  1444. END_OF_FILE
  1445.   if test 6499 -ne `wc -c <'looke.c'`; then
  1446.     echo shar: \"'looke.c'\" unpacked with wrong size!
  1447.   fi
  1448.   # end of 'looke.c'
  1449. fi
  1450. if test -f 'main.c' -a "${1}" != "-c" ; then 
  1451.   echo shar: Will not clobber existing file \"'main.c'\"
  1452. else
  1453.   echo shar: Extracting \"'main.c'\" \(6298 characters\)
  1454.   sed "s/^X//" >'main.c' <<'END_OF_FILE'
  1455. X/*
  1456. X * chemtab - a periodic table data base (C) 1990 Jim King (pulsar@lsrhs)
  1457. X *
  1458. X * main.c    Main program structure and branch
  1459. X */
  1460. X
  1461. X#include <stdio.h>
  1462. X#include <sys/types.h>
  1463. X#include <sys/stat.h>
  1464. X#include <curses.h>
  1465. X#include <time.h>
  1466. X#include <signal.h>
  1467. X
  1468. X#include "variables.h"
  1469. X#include "windows.h"
  1470. X
  1471. X#define    LOCKFILE    "/tmp/chemlock"
  1472. X
  1473. Xextern int    cleanup(), stop();
  1474. Xextern WINDOW    *hlp;
  1475. X
  1476. X/*
  1477. X * main(ac, av) - specify -r flag for ReGIS
  1478. X *
  1479. X * purpose:    Main program branch & menu & inits
  1480. X */
  1481. Xvoid main(ac, av)
  1482. Xint    ac;
  1483. Xchar    *av[];
  1484. X{
  1485. X    long    secs;        /* For logfile */
  1486. X    char    c, str[80];    /* input choice */
  1487. X    int    i, rebuild, textonly, closetext;
  1488. X    struct    stat    *f1, *f2;
  1489. X    
  1490. X    f1 = (struct stat *)malloc(sizeof(struct stat));
  1491. X    f2 = (struct stat *)malloc(sizeof(struct stat));
  1492. X
  1493. X    gtot = -1;
  1494. X#ifdef ReGIS
  1495. X    regis = 0;
  1496. X    strcpy(str, getenv("TERM"));
  1497. X    if ((!strcmp(str, "vt240")) || (!strncmp(str, "vt3", 3))) {
  1498. X        ++regis;
  1499. X        printf("chemtab: ReGIS terminal recognized.  ReGIS mode enabled.\n");
  1500. X        sleep(2);
  1501. X    }
  1502. X    if (ac > 2) {
  1503. X        fprintf(stderr, "chemtab: usage: chemtab [-r]\n");
  1504. X        exit(1);
  1505. X    } else if ((ac == 2) && (av[1][1] == 'r') && (!regis)) {
  1506. X        ++regis;
  1507. X        printf("chemtab: ReGIS mode enabled for this session.\n");
  1508. X        sleep(2);
  1509. X    }
  1510. X
  1511. X#endif ReGIS
  1512. X
  1513. X    if (stat(PERTABLE, f1) == -1) {
  1514. X        printf("Element data (text) is unavailable.\n");
  1515. X        exit(1);
  1516. X    }
  1517. Xlok:    if (stat(BINTABLE, f2) == -1) {
  1518. X        printf("Binary element table is missing.\n");
  1519. X        if (fopen(LOCKFILE, "r") != NULL) {
  1520. X            printf("Someone is already rebuilding the element table.\nPlease wait...\n");
  1521. X            sleep(5);
  1522. X            goto lok;
  1523. X        } else
  1524. X            rebuild++;
  1525. X    } else if (f1->st_mtime > f2->st_mtime) {
  1526. X        printf("Binary element table is outdated.\n");
  1527. X        rebuild++;
  1528. X    }
  1529. X    
  1530. X    if (rebuild) {
  1531. X        if (creat(LOCKFILE, 022) == -1) {
  1532. X            printf("Sorry, cannot create a lockfile.\nProgram will try textfile only.\n");
  1533. X            textonly++;
  1534. X            goto next;
  1535. X        }
  1536. X        printf("Rebuilding binary element table.\n");
  1537. X        sleep(1);
  1538. X        if (readelem() == 888) {
  1539. X            printf("The computer has run out of memory.\n");
  1540. X            exit(1);
  1541. X        }
  1542. X        if (binwritelem() == 888) {
  1543. X            printf("Trouble building binary element table.\nUsing text file, please contact chemtab coordinator.\n");
  1544. X            textonly++;
  1545. X        } else
  1546. X            printf("Binary element table rebuilt.\n");
  1547. X        sleep(1);
  1548. X        unlink(LOCKFILE);
  1549. X    }
  1550. Xnext:    rebuild = 0;  closetext = 0;
  1551. X
  1552. X    initscr();            /* start curses */
  1553. X    hlp = NULL;            /* help screen init */
  1554. X    btm = newwin(1, 79, 23, 0);    /* Bottom line window */
  1555. X    srt = newwin(5, 79, 0, 0);    /* Top sort window */
  1556. X    graph = newwin(0, 0, 0, 0);    /* Whole screen overwrite */
  1557. X    mn = newwin(17, 79, 5, 0);    /* Middle (main) window */
  1558. X    wrefresh(btm); wrefresh(srt); wrefresh(graph); wrefresh(mn);
  1559. X    
  1560. X#ifdef    TRANSCRIPT            /* Log time and user in file */
  1561. X    time(&secs);
  1562. X    bot("Logging you in..");
  1563. X    if ((fp = fopen(TRANSCRIPT, "a+")) != NULL) {
  1564. X        fprintf(fp, "%s logged in at %s", getenv("USER"), ctime(&secs));
  1565. X        fclose(fp);
  1566. X    } else {
  1567. X        bot("Please set the TRANSCRIPT define in tune.h to work on your machine.");
  1568. X        sleep(5);
  1569. X        bot("The program will exit so you can do this now.");
  1570. X        sleep(5);
  1571. X        cleanup();
  1572. X    }
  1573. X#endif    TRANSCRIPT
  1574. X
  1575. X    clear();
  1576. X    mvaddstr(5, 37, "Chemtab");
  1577. X    mvaddstr(9, 28, "Periodic Table Data Base");
  1578. X    mvaddstr(10, 30, "Of the Known Elements");
  1579. X    standout();
  1580. X    mvaddstr(15, 21, "Chemtab 2.01 incorporates online help");
  1581. X    mvaddstr(16, 13, "Answer with a question mark at any question for help.");
  1582. X    standend();
  1583. X    mvaddstr(18, 18, "Version 2.01, January 7th, 1991 by Jim King");
  1584. X    mvaddstr(19, 16, "Developed at Lincoln-Sudbury Regional High School");
  1585. X    mvaddstr(20, 12, "(and) ReGIS package at Rochester Institute of Technology");
  1586. X    refresh();                /* Title page */
  1587. X    spc();
  1588. Xnxt:    mvwaddstr(btm, 0, 0, "Would you like a transcript of graphs and information? ");
  1589. X    wrefresh(btm);    /* transcript flag (trans) */
  1590. X    c = getchar();
  1591. X    if (c == '?') { help(13); goto nxt; }
  1592. X    if (c == 'y') {
  1593. X        trans = 1;
  1594. X        wclear(btm);
  1595. Xl14:        mvwaddstr(btm, 0, 0, "Please enter your last name for the transcript: ");
  1596. X        wrefresh(btm);
  1597. X        echo(); nocrmode();
  1598. X        gets(lnm);
  1599. X        if (lnm[0] == '?') { help(14); goto l14; }
  1600. X        sprintf(str, "%d.chemtab", getpid());
  1601. X        fp = fopen(str, "w");
  1602. X        fprintf(fp, "*** ChemTab - Periodic Table Database - Transcript for >> %s <<", lnm);
  1603. X    }
  1604. X    else if (c != 'n') {
  1605. X        mvwaddstr(btm, 0, 58, "(y, n, or ?) ");
  1606. X        goto nxt;
  1607. X    }
  1608. X    wprintw(btm, "no"); wrefresh(btm);
  1609. X    wclear(btm);
  1610. X    wrefresh(btm);
  1611. X    noecho(); crmode();
  1612. X    clear();
  1613. X    refresh();
  1614. X
  1615. X    bot("Reading in elements...");
  1616. X    if (textonly) {
  1617. X        if (readelem() == 888) {
  1618. Xouch:            printf("The computer has run out of memory.\n");
  1619. X            exit(1);
  1620. X        }
  1621. X    } else
  1622. X        if (binreadelem() == 888) goto ouch;
  1623. X
  1624. X    bot("Reading close values...");
  1625. X    if (getclose() == 888) {
  1626. X        printf("\nThe close value file is corrupt.\n");
  1627. X        exit(1);
  1628. X    }
  1629. X
  1630. X    signal(SIGINT, cleanup);
  1631. X#ifdef    USERSHELL
  1632. X    signal(SIGTSTP, stop);
  1633. X#else    USERSHELL
  1634. X    signal(SIGTSTP, SIG_IGN);
  1635. X#endif    USERSHELL
  1636. X    signal(SIGQUIT, SIG_IGN);
  1637. X    signal(SIGTERM, cleanup);
  1638. X    
  1639. X    for (i = 0; i < 3; i++)            /* initialize sort choices */
  1640. X        dosort[i].wch = 0;
  1641. X
  1642. X    bot(" ");                /* clear the bottom line */
  1643. X
  1644. X    for (;;) {                /* main loop */
  1645. X        wclear(mn);
  1646. X        wrefresh(srt);
  1647. X        upsort();            /* Update the sort window */
  1648. X        for (i = 1; i < 7; i++) {
  1649. X            wmove(mn, i+1, 0);
  1650. X            wprintw(mn, "%d] %s", i, mopts[i]);
  1651. X        }    /* give me choices, then branch off */
  1652. X        menu("Chemtab 2.01 MAIN MENU");
  1653. X#ifdef    ReGIS
  1654. X        mvwaddstr(mn, 11, 0, "^R toggles ReGIS mode which is currently ");
  1655. X        wstandout(mn);
  1656. X        wprintw(mn, "%s", regis ? "on." : "off");
  1657. X        wstandend(mn);
  1658. X#endif    ReGIS
  1659. Xloop:        mvwaddstr(mn, 9, 0, "Your choice? ");
  1660. X        wclrtoeol(mn);
  1661. X        wrefresh(mn);
  1662. X        cur = mn; xp = 14; yp = 9;
  1663. X        noecho();
  1664. X        crmode();
  1665. X        switch(wgetch(mn)) {
  1666. X            case '?': help(15); goto loop;
  1667. X            case '1': looke(); break; /* View specific Element. */
  1668. X            case '2': schar(); esort(); break; /* Select Characteristics */
  1669. X            case '3': wclear(mn); wclear(srt); vdata(); break; /* View Selected Elements */
  1670. X            case '4': wclear(mn); wclear(srt); ptabl(); break; /* Print periodic table.. */
  1671. X#ifdef ReGIS
  1672. X            case '5': wclear(mn); wclear(srt); if (regis) doregisgph(); else dogph(); break;
  1673. X            case '\022': /* ^R */ if (regis) regis = 0; else regis = 1; break;
  1674. X#else ReGIS
  1675. X            case '5': wclear(mn); wclear(srt); dogph(); break; /* Do a graph for us..... */
  1676. X#endif ReGIS
  1677. X            case '6': cleanup(); break; /* Exit */
  1678. X            case '\026': /* ^V */ version(); break;
  1679. X            default: goto loop;
  1680. X        }
  1681. X    }
  1682. X}
  1683. END_OF_FILE
  1684.   if test 6298 -ne `wc -c <'main.c'`; then
  1685.     echo shar: \"'main.c'\" unpacked with wrong size!
  1686.   fi
  1687.   # end of 'main.c'
  1688. fi
  1689. echo shar: End of archive 1 \(of 3\).
  1690. cp /dev/null ark1isdone
  1691. MISSING=""
  1692. for I in 1 2 3 ; do
  1693.     if test ! -f ark${I}isdone ; then
  1694.     MISSING="${MISSING} ${I}"
  1695.     fi
  1696. done
  1697. if test "${MISSING}" = "" ; then
  1698.     echo You have unpacked all 3 archives.
  1699.     rm -f ark[1-9]isdone
  1700. else
  1701.     echo You still must unpack the following archives:
  1702.     echo "        " ${MISSING}
  1703. fi
  1704. exit 0
  1705. exit 0 # Just in case...
  1706.